Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add option to create JSON info files #2192

Closed
wants to merge 1 commit into from

Conversation

aparcar
Copy link
Member

@aparcar aparcar commented Jul 3, 2019

The JSON info files contain details about the created firmware images
per device and are stored next to the created images.

The JSON files are stored as "$(IMAGE_PREFIX).json" and contain some
device/image meta data as well as a list of created firmware images.

An example of openwrt-ramips-rt305x-aztech_hw550-3g.json

{
  "id": "aztech_hw550-3g",
  "image_prefix": "openwrt-ramips-rt305x-aztech_hw550-3g",
  "images": [
    {
      "name": "openwrt-ramips-rt305x-aztech_hw550-3g-squashfs-sysupgrade.bin",
      "sha256": "db2b34b0ec4a83d9bf612cf66fab0dc3722b191cb9bedf111e5627a4298baf20",
      "type": "sysupgrade"
    }
  ],
  "metadata_version": 1,
  "supported_devices": [
    "aztech,hw550-3g",
    "hw550-3g"
  ],
  "target": "ramips/rt305x",
  "titles": [
    {
      "model": "HW550-3G",
      "vendor": "Aztech"
    },
    {
      "model": "ALL0239-3G",
      "vendor": "Allnet"
    }
  ],
  "version_commit": "r10920+123-0cc87b3bac",
  "version_number": "SNAPSHOT"
}

Signed-off-by: Paul Spooren mail@aparcar.org

@aparcar aparcar force-pushed the CREATE_JSON branch 4 times, most recently from 2a2bda1 to 40ed190 Compare July 4, 2019 15:05
@aparcar aparcar changed the title [wip]build: add option to create JSON info files build: add option to create JSON info files Jul 4, 2019
@adschm
Copy link
Member

adschm commented Jul 4, 2019

After each build process all JSON files are merged in a single devices.json file only containing title and device ID.

Had to think twice about that: JSON files are NOT merged, but selective information about them is collected in devices.json ...

@adschm
Copy link
Member

adschm commented Jul 4, 2019

"8devices Carambola2": "8dev_carambola2"

Do you have a reason why you use the friendly name as key and the ID as value? I would have done it the other way around, so the ID is used as ID (although it technically won't matter if I got your use-case right)

scripts/add_json.sh Outdated Show resolved Hide resolved
@dedeckeh dedeckeh added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Jul 4, 2019
@aparcar
Copy link
Member Author

aparcar commented Jul 5, 2019

After each build process all JSON files are merged in a single devices.json file only containing title and device ID.

Had to think twice about that: JSON files are NOT merged, but selective information about them is collected in devices.json ...

devices.json is like a map, on what devices are available.

Do you have a reason why you use the friendly name as key and the ID as value? I would have done it the other way around, so the ID is used as ID (although it technically won't matter if I got your use-case right)

Idea is to search trough the keys via a fuzzy search, once a device is found more detailed information are gathered via the <device_id>.json

@aparcar aparcar force-pushed the CREATE_JSON branch 2 times, most recently from 86a128f to 4fa6e5f Compare July 5, 2019 10:07
@adschm
Copy link
Member

adschm commented Jul 5, 2019

devices.json is like a map, on what devices are available.

I'm aware of that, I just wanted to advice on changing the part in the commit message/PR description where you say "merged" to make it clearer.

@adschm
Copy link
Member

adschm commented Jul 5, 2019

Idea is to search trough the keys via a fuzzy search, once a device is found more detailed information are gathered via the <device_id>.json

Well, I still would exchange key and value and then search through the values.

@aparcar
Copy link
Member Author

aparcar commented Jul 5, 2019

exchanged key and value, also clarified the commit message

@aparcar
Copy link
Member Author

aparcar commented Jul 7, 2019

@jow- please have a look

@aparcar
Copy link
Member Author

aparcar commented Jul 7, 2019

Here is an example for resulting files https://chef.libremesh.org/download/json/

@aparcar
Copy link
Member Author

aparcar commented Jul 13, 2019

@blogic I moved the output to $(TOPDIR)/bin/json/. Would that work for you?

@lynxis
Copy link
Member

lynxis commented Jul 15, 2019

I would like to have a hash (sha256) of glinet_gl-ar150.json into the devices.json.
If we have this, we could sign devices.json and have a valid path down to the image. I see value in this, even if the images are signed itself.

I'm also missing a version field of the json structure. I mean the api/specification of the json field.

@aparcar
Copy link
Member Author

aparcar commented Jul 15, 2019

The approach was changed, now maps.json and overview.json are ingame to solve two issues at once: vanilla firmware upgrades and firmware search! The script became to complex to use purse shell, but as Python3 becomes (is?) a buildroot dependency anyway, that shouldn't cause any problem.

If a (to be designed) release.json file is signed and contains checksums of the maps.json file, a secure chain is created as long as sha256 isn't broken.

@aparcar aparcar force-pushed the CREATE_JSON branch 2 times, most recently from f8b7eff to 4d58d3b Compare July 16, 2019 16:04
@aparcar
Copy link
Member Author

aparcar commented Jul 16, 2019

Now uses two Python3 scripts instead of messy shell scripts. Also a map file is created per subtarget.

@aparcar
Copy link
Member Author

aparcar commented Jul 16, 2019

Now also handles ALT titles

sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 25, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 25, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 25, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 26, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 26, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 26, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
sudhanshug16 added a commit to sudhanshug16/luci that referenced this pull request Aug 26, 2019
Utilises the JSON schema generated after build as suggested in:
openwrt/openwrt#2192 (comment)

Ability to apply fresh images (default packages only, from openwrt)
or to apply image with installed packages (from attendedsysupgrade server)

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
@aparcar
Copy link
Member Author

aparcar commented Aug 27, 2019

Please see the outcome of this years GSoC here. It's a firmware wizard which utilizes the JSON produced in this PR to allow users simple selection of firmware. It also supports images on demand for custom package selections, please have a look.

image

image

aparcar added a commit to aparcar/openwrt-metabuilder that referenced this pull request Sep 1, 2019
While unmerged, patch it here
openwrt/openwrt#2192

Signed-off-by: Paul Spooren <mail@aparcar.org>
aparcar added a commit to aparcar/openwrt that referenced this pull request Sep 1, 2019
This is a proof of conecpt and requires further work, it show how a
device can find upgrades only in a secure way, without any extra
packages, especially nothing HTTPS related.

The online.sh "library" can be used for CLIs or ubus calls for Luci or
other webinterfaces to come.

Details about the JSON structure are explained in another PR[0].

To try the script, run `sysupgrade-online --search` or `--unattended`,
the former searches for a sysupgrade (only snapshots currently), the
latter searches and passes results to a download function, which then
downloaded the sysupgrade.

Ideally the sysupgrade would be verified aditionally via usign.

[0]: openwrt#2192

Signed-off-by: Paul Spooren <mail@aparcar.org>
@aparcar
Copy link
Member Author

aparcar commented Sep 2, 2019

I created a proof of concept on how devices could find securely firmware upgrades.

@jow-
Copy link
Contributor

jow- commented Sep 13, 2019

Where do these file end up? Are the JSON files really put next to the image files?
Does the merging really need to be part of buildroot? Can't this be done elsewhere?

@aparcar
Copy link
Member Author

aparcar commented Sep 14, 2019

It's not important to store the files next to the images, but putting them next to buildinfo and manifest files seemed reasonable to me. If you'd prefer so, I'd move the files to a different folder. However I'd really be in favor to have this files created by the buildbot. I see three use cases which all require up to date JSON files.

Removing the merging process from the buildroot be possible via the json overview but still, I'd much more like to see these files officially distributed at downloads.openwrt.org.

@aparcar aparcar force-pushed the CREATE_JSON branch 2 times, most recently from f013c3e to 94610a3 Compare September 19, 2019 22:42
@aparcar
Copy link
Member Author

aparcar commented Sep 19, 2019

@jow- I removed the merging for now as this can be done somewhere else as well. Also enabled it only for buildbots by default.

aparcar added a commit to aparcar/openwrt-metabuilder that referenced this pull request Sep 28, 2019
While unmerged, patch it here
openwrt/openwrt#2192

Signed-off-by: Paul Spooren <mail@aparcar.org>
The JSON info files contain details about the created firmware images
per device and are stored next to the created images.

The JSON files are stored as "$(IMAGE_PREFIX).json" and contain some
device/image meta data as well as a list of created firmware images.

An example of openwrt-ramips-rt305x-aztech_hw550-3g.json

    {
      "id": "aztech_hw550-3g",
      "image_prefix": "openwrt-ramips-rt305x-aztech_hw550-3g",
      "images": [
        {
          "name": "openwrt-ramips-rt305x-aztech_hw550-3g-squashfs-sysupgrade.bin",
          "sha256": "db2b34b0ec4a83d9bf612cf66fab0dc3722b191cb9bedf111e5627a4298baf20",
          "type": "sysupgrade"
        }
      ],
      "metadata_version": 1,
      "supported_devices": [
        "aztech,hw550-3g",
        "hw550-3g"
      ],
      "target": "ramips/rt305x",
      "titles": [
        {
          "model": "HW550-3G",
          "vendor": "Aztech"
        },
        {
          "model": "ALL0239-3G",
          "vendor": "Allnet"
        }
      ],
      "version_commit": "r10920+123-0cc87b3bac",
      "version_number": "SNAPSHOT"
    }

Signed-off-by: Paul Spooren <mail@aparcar.org>
@dangowrt
Copy link
Member

Cherry-picked on master. Thanks!

@dangowrt dangowrt closed this Sep 29, 2019
@@ -7,6 +7,13 @@

menu "Global build settings"

config JSON_ADD_IMAGE_INFO
bool "Create JSON info files per build image"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be per built image ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually even files per build profile, as a profile may contain multiple images (factory, sysupgrade,...). Will update that

bool "Create JSON info files per build image"
default BUILDBOT
help
The JSON info files contain information about the device and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

The generated JSON files, named after the base name of image (e.g. "openwrt-ath79-generic-8dev_carambola2..."), will be stored in the same directory as built image files.

Each JSON file contains meta information about the devices supported by a family of images
and the image files belonging to a particular family.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you I will update that

@aparcar
Copy link
Member Author

aparcar commented Oct 12, 2019

@jow- The currently missing json files on download.openwrt.org are due to the prepare step happening after target/install. I wrote that earlier in IRC

would it be possible to run "make prepare" before "target/install"? from my understanding it should just generate buildinfo files. However it seem to trigger "Device/Build" from include/image.mk which clean up the json files

I don't see a reason why prepare shouldn't run before target/install, it is only required to run after the feeds update to have correct commits per feed in feeds.buildinfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/scripts/tools pull request/issues for build, scripts and tools related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants